<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    div{
        width: 100px;
        height:100px;
        background-color: brown;
        position: absolute;
        left: 0;
        top: 0;
    }
</style>
<body>
    <h2>鼠标绑定小盒子</h2>
    <div id="divv"></div>
    <script>
        let div = document.getElementById('divv');
        document.onmousemove = function (params) {
            let eb =params || window.event;
            div.style.left = event.clientX - div.offsetWidth/2+ 'px';
            div.style.top = event.clientY -div.offsetHeight/2 + 'px';
        }

    </script>
</body>
</html>